Skip to content

feat: add return type and property type mismatch diagnostics#220

Open
calebdw wants to merge 1 commit into
mainfrom
calebdw/push-mknwnlmknmok
Open

feat: add return type and property type mismatch diagnostics#220
calebdw wants to merge 1 commit into
mainfrom
calebdw/push-mknwnlmknmok

Conversation

@calebdw

@calebdw calebdw commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator

Add two new diagnostic collectors to the type mismatch family:

  • type_mismatch_return: checks return statements against declared return types. Flags incompatible types, void functions returning values, and bare return; in non-void functions. Skips generators, abstract methods, mixed/untyped returns.

  • type_mismatch_property: checks $this->prop and self::$prop assignments against declared property types. Only plain = assignments; compound operators are skipped.

Both reuse the existing is_type_compatible() policy layer and resolve_expression_type() infrastructure. A unified collect_type_mismatch_diagnostics() entry point groups all three collectors (argument, return, property).

Closes #201

@calebdw calebdw force-pushed the calebdw/push-mknwnlmknmok branch from 9cf394a to f48ba67 Compare July 10, 2026 13:59
@codecov-commenter

codecov-commenter commented Jul 10, 2026

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 85.87444% with 126 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/diagnostics/return_type_errors.rs 88.28% 67 Missing ⚠️
src/diagnostics/property_type_errors.rs 82.60% 52 Missing ⚠️
src/analyse.rs 0.00% 7 Missing ⚠️

📢 Thoughts on this report? Let us know!

@calebdw calebdw requested a review from AJenbo July 10, 2026 14:08
@calebdw calebdw force-pushed the calebdw/push-mknwnlmknmok branch from f48ba67 to 272f9d5 Compare July 10, 2026 17:29
@AJenbo

AJenbo commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

This is surfacing a bunch of false positives that we need to resolve first, aka merging after 0.9.0

@calebdw calebdw marked this pull request as draft July 10, 2026 17:42
@calebdw calebdw force-pushed the calebdw/push-mknwnlmknmok branch 2 times, most recently from 5eda8f3 to 7281dd8 Compare July 10, 2026 19:00
@calebdw

calebdw commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator Author

Can you post some examples of these false positives?

@calebdw calebdw force-pushed the calebdw/push-mknwnlmknmok branch 7 times, most recently from d2d3665 to 0fc9019 Compare July 15, 2026 14:49
@calebdw calebdw marked this pull request as ready for review July 15, 2026 15:54
@calebdw calebdw force-pushed the calebdw/push-mknwnlmknmok branch from 0fc9019 to 55efddc Compare July 15, 2026 16:46
Add two new diagnostic collectors to the type mismatch family:

- type_mismatch_return: checks return statements against declared
  return types. Flags incompatible types, void functions returning
  values, and bare return; in non-void functions. Skips generators,
  abstract methods, mixed/untyped returns.

- type_mismatch_property: checks $this->prop and self::$prop
  assignments against declared property types. Only plain =
  assignments; compound operators are skipped.

Both reuse the existing is_type_compatible() policy layer and
resolve_expression_type() infrastructure. A unified
collect_type_mismatch_diagnostics() entry point groups all three
collectors (argument, return, property).

Closes #201
@calebdw calebdw force-pushed the calebdw/push-mknwnlmknmok branch from 55efddc to 092f9d4 Compare July 15, 2026 19:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

emit diagnostic for invalid code

3 participants